home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / sticpsrc.lzh / SOURCE.ARC / ARP.H < prev    next >
C/C++ Source or Header  |  1990-01-01  |  3KB  |  84 lines

  1. /* Size of ARP hash table */
  2. #define ARPSIZE 17
  3.  
  4. /* Lifetime of a valid ARP entry */
  5. #define ARPLIFE        900    /* 15 minutes */
  6. /* Lifetime of a pending ARP entry */
  7. #define PENDTIME    30    /* 30 seconds */
  8.  
  9. /* ARP definitions (see RFC 826) */
  10.  
  11. /* Address size definitions */
  12. #define IPALEN    4        /* Length in bytes of an IP address */
  13. #define MAXHWALEN    255    /* Maximum length of a hardware address */
  14.  
  15. /* ARP opcodes */
  16. #define ARP_REQUEST    1
  17. #define ARP_REPLY    2
  18.  
  19. /* Hardware types */
  20. #define ARP_NETROM    0    /* Fake for NET/ROM (never actually sent) */
  21. #define ARP_ETHER    1    /* Assigned to 10 megabit Ethernet */
  22. #define ARP_EETHER    2    /* Assigned to experimental Ethernet */
  23. #define ARP_AX25    3    /* Assigned to AX.25 Level 2 */
  24. #define ARP_PRONET    4    /* Assigned to PROnet token ring */
  25. #define ARP_CHAOS    5    /* Assigned to Chaosnet */
  26. #define ARP_ARCNET    7
  27. #define ARP_APPLETALK    8
  28. extern char *arptypes[];    /* Type fields in ASCII, defined in arptypes.c */
  29. #define NHWTYPES 9
  30.  
  31. /* Table of hardware types known to ARP */
  32. struct arp_type {
  33.     int16 hwalen;        /* Hardware length */
  34.     int16 iptype;        /* Hardware type field for IP */
  35.     int16 arptype;        /* Hardware type field for ARP */
  36.     char *bdcst;        /* Hardware broadcast address */
  37.     int (*format)();    /* Function that formats addresses */
  38.     int (*scan)();        /* Reverse of format */
  39. };
  40. extern struct arp_type arp_type[];
  41. #define NULLATYPE    (struct arp_type *)0
  42.  
  43. /* Format of an ARP request or reply packet. From p. 3 */
  44. struct arp {
  45.     int16 hardware;            /* Hardware type */
  46.     int16 protocol;            /* Protocol type */
  47.     char hwalen;            /* Hardware address length, bytes */
  48.     char pralen;            /* Length of protocol address */
  49.     int16 opcode;            /* ARP opcode (request/reply) */
  50.     char shwaddr[MAXHWALEN];    /* Sender hardware address field */
  51.     int32 sprotaddr;        /* Sender Protocol address field */
  52.     char thwaddr[MAXHWALEN];    /* Target hardware address field */
  53.     int32 tprotaddr;        /* Target protocol address field */
  54. };
  55.  
  56. /* Format of ARP table */
  57. struct arp_tab {
  58.     struct arp_tab *next;    /* Doubly-linked list pointers */
  59.     struct arp_tab *prev;
  60.     int32 ip_addr;        /* IP Address, host order */
  61.     struct interface *interface; /* Interface (when automatic entry) */
  62.     int16 hardware;        /* Hardware type */
  63.     char *hw_addr;        /* Hardware address */
  64.     char state;        /* (In)complete */
  65. #define ARP_PENDING    0
  66. #define ARP_VALID    1
  67.     char pub;        /* Respond to requests for this entry? */
  68.     struct timer timer;    /* Time until aging this entry */
  69.     struct mbuf *pending;    /* Queue of datagrams awaiting resolution */
  70. };
  71. struct arp_tab *arp_lookup(),*arp_add();
  72. #define NULLARP (struct arp_tab *)0
  73. extern struct arp_tab *arp_tab[];
  74.  
  75. struct arp_stat {
  76.     unsigned recv;        /* Total number of ARP packets received */
  77.     unsigned badtype;    /* Incoming requests for unsupported hardware */
  78.     unsigned badlen;    /* Incoming length field(s) didn't match types */
  79.     unsigned badaddr;    /* Bogus incoming addresses */
  80.     unsigned inreq;        /* Incoming requests for us */
  81.     unsigned replies;    /* Replies sent */
  82.     unsigned outreq;    /* Outoging requests sent */
  83. };
  84.